<@admin.header title="汽车列表">
<#setting datetime_format="yyyy-MM-dd"/>
<script type="text/javascript">
    $(document).ready(function(){
		App.ns('Car');
		
		
		Car.form = new App.common.Form({
			base:'${base}/car'
		});
		
		
		Car.search = function(){
			$('#searchForm').submit();
		}
		Car.delAll = function(){
			var ids = Car.form.getCheckboxValues();
			Car.form.deleteRecord(ids);
		}
		Car.del = function(ids){
			Car.form.deleteRecord(ids,null, function(){
				$("#tr_"+ids).hide();
				App.toast.success("操作成功");
			});
		}
		/**
		 * 改变汽车是否为特价的属性
		 * @param {Object} id
		 */
		Car.specialPrice=function(id){
			App.ajax.post("car/specialPrice.do",{"id":id},function(d){
				if(d.success){
					App.toast.success("操作成功");
					$("#special_"+id).html(d.message=="0"?"否":"是");
				}else{
					APp.toast.error(d.message);
				}
			});
		}
		//修改汽车的待售信息
		Car.status=function(id){
			App.ajax.post("car/status.do",{"id":id},function(d){
				if(d.success){
					App.toast.success("操作成功");
					if(d.message=="0"){
						$("#status_"+id).removeClass("red").html("待售");
					}else
						$("#status_"+id).addClass("red").html("已售");
				}else{
					APp.toast.error(d.message);
				}
			});
		}
    });
	
</script>
<style>
	.red {color:#f11;font-weight:bold;}
	.line {line-height:100%;text-indent:3px;word-break:break-all;}
</style>
</@admin.header>
    <body>
        <div class="place">
            <span>位置：</span>
            <ul class="placeul">
                <li>
                    <a href="#">首页</a>
                </li>
                <li>
                    <a href="#">二手车管理</a>
                </li>
                <li>
                    <a href="">汽车列表</a>
                </li>
            </ul>
        </div>
        <div class="rightinfo" style="min-width:1200px;">
        <!--默认查询表单-->
        <form action="list.do" method="post" id="searchForm">
            <input type="hidden" name="pageNo" value="1"/>
            <div class="tools">
                <ul class="toolbar">
                    <li class="click">
                        <a href="add.do"><span><img src="${base}/resources/images/t01.png" /></span>添加</a>
                    </li>
                    <li>
                        <a href="javascript:Car.delAll();"><span><img src="${base}/resources/images/t03.png" /></span>删除</a>
                    </li>
                    <li style="padding:0 0">
                        <span style="margin:0px 5px">关键字</span>
	                	<input name="keyword" type="text" value="${keyword!''}" class="dfinput" style="width:160px;" />&nbsp;
                    </li>
                    <li>
						<a href="javascript:Car.search()"><span><img src="${base}/resources/images/search24.png" /></span>查找</a>
                    </li>
                </ul>
            </div>
			</form>
            <table class="tablelist" style="width:100%; ">
                <thead>
                    <tr>
                        <th width="30"><input name="" type="checkbox" onclick="Car.form.checkToggle('ids',this);"/></th>
						<th width="60">编号</th>
						<th>名称</th>
						<th width="100">归属地</th>
						<th width="100">车牌号</th>
						<th width="100">上牌时间</th>
						<th width="100">年检到期</th>
						<th width="60">里程</th>
						<th width="60">特价?</th>
						<th width="60">状态</th>
						<th width="60">站内价</th>
						<th width="60">新车价</th>
                        <th width="100">发布时间</th>
                        <th width="205">操作</th>
                    </tr>
                </thead>
                <tbody>
                	
                	<#if page??>
					<#list page.list as d>
                    <tr id="tr_${d.id}">
                        <td>
                            <input name="ids" type="checkbox" value="${d.id}" />
                        </td>
						<td>${d_index+1}</td>
						<td>
						<div class="line">
                        <#if keyword?? && keyword != "">
                        ${d.fullName?replace(keyword,"<span class='red'>"+keyword+"</span>")}
						<#else>
						${d.fullName!''}
						</#if>
						</div>
						</td>
						<td>${d.belong!''}</td>
						<td>${d.plateNumber!''}</td>
						<td>${d.plateDate!''}</td>
						<td>${d.checkDate!''}</td>
						<td>${d.mileage!''}</td>
						<td>
							<a href="javascript:;" onclick="Car.specialPrice(${d.id})" id="special_${d.id}" title="点击来改变是否为特价车">
							<#if d.specialPrice=0>否<#else>是</#if>
							</a>
						</td>
						<td>
							<a href="javascript:;" onclick="Car.status(${d.id})" class="<#if d.status gt 0>red</#if>" 
								id="status_${d.id}" title="点击来改变汽车的销售状态">
							<#if d.status=0>待售<#else>已售</#if>
							</a>
						</td>
						<td>${d.price}万</td>
						<td>${d.freshPrice}万</td>
						<td>${d.postDate!''}</td>
                        <td style="padding:0px;">
                            <a href="add.do?template=basic&id=${d.id}" class="tablelink">基本信息</a>
							&nbsp;
							<a href="add.do?template=picture&id=${d.id}" class="tablelink">图片</a>
							&nbsp;
							<a href="add.do?template=configure&id=${d.id}" class="tablelink">配置</a>
							&nbsp;
							<a href="add.do?template=report&id=${d.id}" class="tablelink">测评</a>
							&nbsp;
                        	<a href="javascript:Car.del('${d.id}')" class="tablelink">删除</a>
                        </td>
                    </tr>
					</#list>
					</#if>
                </tbody>
            </table>
			<@common.pagination />
        </div>
    </body>
</html>